package company.bytedance

import java.util.concurrent.CountDownLatch


fun main(args: Array<String>) {


}


class Printer {

    var number = 0;

    var reentrantLock = CountDownLatch(3)

    fun print() {


        reentrantLock.countDown()
        println("${Thread.currentThread().name}打印$number")
        number++

        reentrantLock.await()
    }
}

fun printInterval() {

    val printer = Printer()
    for (i in 0 until 3) {

        Thread({
            printer.print()
        }, "thread$i").start()

    }
}